<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> 
<head>
<title>XSD Sample</title>
<link rel="stylesheet" type="text/css" href="../../../docs/rotor.css">
</head>

<body>		


<h1> XSD Sample</h1>


<h2>Sample Overview</h2>


<P>The XML Schema Definition  tool generates XML schema or managed classes 
from XDR, XML, and XSD files, or from classes in an assembly. </P>

<P>Note: The  Shared Source CLI (SSCLI) implementation does not 
include support for <b>System.Data.*</b> classes. The  Microsoft Visual Basic&reg; 2005
compiler is also not supported on the SSCLI 2.0.</P>

<p>The SSCLI implementation does not support Visual Basic 2005 as a target 
language and does not support dataset functionality.&nbsp; The following options 
that are available in the .NET Framework implementation of XSD are not supported 
in the SSCLI version.</p>
<ul>
  <li>The <b>/d[ataset]</b> option is not supported.&nbsp; This option generates 
  a class derived from DataSet that corresponds to the specified schema. </li>
  <li>The <i>VB</i> value is not supported with the<b> /l </b>language option.</li>
  <li>Inference of schemas from .XML files is not supported.</li>
</ul>

<h4>Usage</h4>

<blockquote>

<pre>clix xsd <I>file.xdr </I>[<B>/outputdir:</B><I>directory</I>]<br>
clix xsd <I>file.xsd </I>{<B>/classes</B>} [<B>/element:</B><I>element</I>]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<B>/language:</B><I>language</I>] [<B>/namespace:</B><I>namespace</I>]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [<B>/outputdir:</B><I>directory</I>] [<B>URI:</B><I>uri</I>]<br>
clix xsd {<I>file.dll | file.exe} </I>[<B>/outputdir:</B><I>directory</I>] [<B>/type:</B><I>typename </I>[...]]</pre>
</blockquote>
<table border=1>

<TR VALIGN="top">
<TH width=33%>Argument</TH>
<TH width=67%>Description</TH>
</TR>

<TR VALIGN="top">
<TD width=33%><I>file.extension</I></TD>
<TD width=67%>The input file to convert.  You must specify the <I>extension </I>
as one of the following: .xdr, .xsd, .dll, or .exe.

<P>If you specify an XML schema file (.xsd extension), the xsd sample tool generates source code for runtime objects that correspond to the XML schema. </P>

<P>If you specify a runtime assembly file (.exe or .dll extension), the XML 
Schema Definition tool generates schemas for one or more types in that assembly.  You can use the <B>/type</B> option to specify the types for which to generate schemas. The output schemas are named schema0.xsd, schema1.xsd, and so on. The  tool produces multiple schemas only if the given types specify a namespace using the <B>XmlRoot</B> custom attribute. </P>
</TD>
</TR>
</table>

<H4>General Options</H4>

<p>Options can be specified using either a dash (-) or a slash (/). </p>
<table border=1>

<TR VALIGN="top">
<TH width=33%>Option</TH>
<TH width=67%>Description</TH>
</TR>

<TR VALIGN="top">
<TD width=33%><B>/h</B>[<B>elp</B>]</TD>
<TD width=67%>Displays command syntax and options for the tool.</TD>
</TR>

<TR VALIGN="top">
<TD width=33%><B>/o</B>[<B>utputdir</B>]<B>:</B><I>directory</I></TD>
<TD width=67%>Specifies the directory for output files.  This argument can appear only once. The default is the current directory.</TD>
</TR>

<TR VALIGN="top">
<TD width=33%><B>/?</B></TD>
<TD width=67%>Displays command syntax and options for the tool.<p>When using 
this tool on  UNIX system-based platforms, <b>/?</b> might expand to a filename. Instead 
use the <b>/help</b> option variation, use <b>-?</b>, or enclose the <b>/?</b> option in quotes: &quot;<b>/?</b>&quot;</TD>
</TR>
</table>

<H4>XSD File Options</H4>

<P>You must specify only one of the following options for .xsd files.</P>
<table border=1>

<TR VALIGN="top">
<TH width=33%>Option</TH>
<TH width=67%>Description</TH>
</TR>

<TR VALIGN="top">
<TD width=33%><B>/c</B>[<B>lasses</B>]</TD>
<TD width=67%>Generates classes that correspond to the specified schema.  To read XML data into the object, use the 
<b>System.XML.Serialization.XMLSerializer.Deserializer</b> method.</TD>
</TR>

</table>

<P>You can also specify any of the following options for .xsd files.</P>
<table border=1>

<TR VALIGN="top">
<TH width=33%>Option</TH>
<TH width=67%>Description</TH>
</TR>

<TR VALIGN="top">
<TD width=33%><B>/e</B>[<B>lement</B>]<B>:</B><I>element</I></TD>
<TD width=67%>Specifies the element in the schema to generate code for.  By default all elements are typed.  You can specify this argument more than once. </TD>
</TR>

<TR VALIGN="top">
<TD width=33%><B>/l</B>[<B>anguage</B>]<B>:</B><I>language</I></TD>
<TD width=67%>Specifies the programming language to use.  Choose from <B>CS</B> (default<I>)</I>, or<B> JS</B>. You can also specify a fully qualified name for a class implementing 
<b>System.CodeDom.Compiler.CodeDomProvider</b>.</TD>
</TR>

<TR VALIGN="top">
<TD width=33%><B>/n</B>[<B>amespace</B>]<B>:</B><I>namespace</I></TD>
<TD width=67%>Specifies the runtime namespace for the generated types. The default namespace is <B>Schemas</B>.</TD>
</TR>

<TR VALIGN="top">
<TD width=33%><B>/u</B>[<B>ri</B>]<B>:</B><I>uri</I></TD>
<TD width=67%>Specifies the URI for the elements in the schema to generate code for.  This URI, if present, applies to all elements specified with the <B>/element</B> option.</TD>
</TR>
</table>

<H4>Assembly File Options</H4>
<table border=1>

<TR VALIGN="top">
<TH width=33%>Option</TH>
<TH width=67%>Description</TH>
</TR>

<TR VALIGN="top">
<TD width=33%><B>/t</B>[<B>ype</B>]<B>:</B><I>typename</I></TD>
<TD width=67%>Specifies the name of the type to create a schema for.  You can specify multiple type arguments. If <I>typename</I> does not specify a namespace, 
the XML Schema Definition tool matches all types in the assembly with the specified type.  If <I>typename</I> specifies a namespace, only that type is matched.  If <I>typename</I> ends with an asterisk character (*), the tool matches all types that start with the string preceding the *.  If you omit the <B>/type</B> option, 
the  tool generates schemas for all types in the assembly.</TD>
</TR>
</table>

<H4>Remarks</H4>

<P>The XML Schema Definition tool performs the following operations:

<h4>XSD to Classes </h4>

<DL>

<DD>Generates runtime classes from an XSD schema file.  The generated classes can be used in conjunction with 
<b>System.XML.Serialization.XMLSerializer</b> to read and write XML code that follows the schema.</dd>
</DL>

<h4>Classes to XSD </h4>

<DL>

<DD>Generates an XML schema from a type or types in a runtime assembly file.  The generated schema defines the XML format used by
<b>System.XML.Serialization.XMLSerializer</b>.</dd>
</DL>

<P>The  tool only allows you to manipulate XML schemas that follow the 
XML Schema definition (XSD) language proposed by the World Wide Web Consortium 
(W3C). For more information on the XML Schema definition proposal or the XML 
standard, see http://w3c.org</P>

<h2>Sample Source and Build Output Locations</h2>


<p>The sample source is found in sscli20\samples\utilities\xsd.&nbsp; </p>


<p>The source file is:</p>


<ul class="none">
  <li><a href="xsd.cs">xsd.cs</a></li>
</ul>


<p>The build output location is %_NTTREE%\samples\utilities\xsd.&nbsp; The 
output file is an executable assembly named xsd.exe.</p>


<h2>Building the Sample</h2>


<p>All samples are built from the buildall script.&nbsp;  </p>


<p>You can also build all the 
samples by switching to the root of the sample directory, sscli20\samples, and typing 
<code>build -c</code>.</p>


<p>You can build this specific sample  by switching to the sample directory and typing 
<code>build -c</code>.</p>


<h2>Running the Sample</h2>


<p>These steps require that the Shared Source CLI (SSCLI) be already built and 
functional.</p>


<ol>
  <li>Run  env.bat. </li>
  <li>Switch to the %_NTTREE%\samples\utilities\xsd directory.</li>
  <li>Type the following command:<blockquote>


<p>clix xsd.exe <i>xsdfile</i></p>


  </blockquote>


  </li>
</ol>



<p><i>Copyright (c) 2006 Microsoft Corporation. All rights reserved.</i></p>
</body> 
</html>